package com.example.back.mapper;

import com.example.back.model.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Select("select * from product")
    List<Product> findAllProduct();
    @Select("select * from product order by type")
    List<Product> findOrderByType();
    @Select("select * from product where type=#{type}")
    List<Product> findProductByType(String type);
    @Select("select * from product where instr(name, #{name})>0")
    List<Product> selectGName(String name);
    @Insert("insert into product(name, price, unit, type) values(#{name}, #{price}, #{unit}, #{type})")
    Boolean insertProduct(String name, double price, String unit, String type);
    @Update("update product set price=#{price} where id=#{id}")
    Boolean updateProduct(int id, double price);
    @Delete("delete from product where id=#{id}")
    Boolean deleteProduct(int id);
    @Select("select photo from product where id=#{id}")
    String findPhotoByID(int id);
}
